package dletc.job.job03;

public class Order {

	/*1.编写Order类，有int型的orderId，String型的orderName，
	相应的 getter()和setter()方法，两个参数的构造器，重写父类的equals()方法：
	public boolean equals(Object obj)，并判断测试类中创建的两个对象是否相等*/
	private int orderId;
	private String orderName;
	
	public Order() {

	}

	public Order(int orderId, String orderName) {
		this.orderId = orderId;
		this.orderName = orderName;
	}

	public int getOrderId() {
		return orderId;
	}

	public void setOrderId(int orderId) {
		this.orderId = orderId;
	}

	public String getOrderName() {
		return orderName;
	}

	public void setOrderName(String orderName) {
		this.orderName = orderName;
	}


	/*@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Order other = (Order) obj;
		if (orderId != other.orderId)
			return false;
		if (orderName == null) {
			if (other.orderName != null)
				return false;
		} else if (!orderName.equals(other.orderName))
			return false;
		return true;
	}*/
	
	
	@Override
	public boolean equals(Object obj) {
		//重写equals方法
		//第一步 判断是否是同一个对象
		if(this == obj) return true;
		//第二步：判断是否为null 且 类型是否是  Order（要比较的类型）
		if(obj != null && obj instanceof Order){
			Order o = (Order)obj;
			//第三步：具体的条件对比
			return this.getOrderId() == o.getOrderId() && 
					this.getOrderName().equals(o.getOrderName());
		}else return false; //第四步 以上都不对 输出 false
			
		
	}
	
	

}
